# pip install screeninfo 
# 
import numpy as np
import cv2
import screeninfo
 
 
def gen_board(board_size, squre_size):
	'''
	@board_size: board grid num (horz, vert)
	@squre_size: board squre length, unit:mm 
	'''
	# ppmm: pixels per mm
	ppmm_x = 1920 / 476 # Monitor.width / Monitor.width_mm
	ppmm_y = 1080 / 268 # Monitor.height / Monitor.height_mm
 
	# rect_pixels
	rect_width  = int( ppmm_x * squre_size )
	rect_height = int( ppmm_y * squre_size )
 
	img_width = board_size[0] * rect_width
	img_height = board_size[1] * rect_height
	print("board: grid={0}, img={1}".format((rect_width, rect_height), (img_width, img_height)))
 
	img = np.ones((img_height, img_width, 3), dtype=np.uint8)
 
	pixel = 255
	for y in range(0, img_height, rect_height):
		colr_grid = [pixel, pixel, pixel]
		for x in range(0, img_width, rect_width):
			cv2.rectangle(img, (x, y, rect_width, rect_height), colr_grid, -1)
			# next col
			colr_grid[0] = 255 - colr_grid[0]
			colr_grid[1] = 255 - colr_grid[1]
			colr_grid[2] = 255 - colr_grid[2]
		# next row
		pixel = 255 - pixel
 
	cv2.imwrite("board.png", img)
 
def main():
	for m in screeninfo.get_monitors():
		print(str(m))
 
	# board size: 9,7
	# board squre length=25mm
	gen_board((9, 7), 25)
 
if __name__ == '__main__':
	main()